#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()//2022 1 1     0 0 0
{
	
	vector<int> ret;
	int tmp=0;
	int year,month,day,h,min,s;
	while(scanf("%d-%d-%d %d:%d:%d",&year,&month,&day,&h,&min,&s)==6)
	{
		int sum=0;
		for(int i=0;i<month;++i)
		{
			sum+=d[i];
		}
		sum+=day;
		sum=sum*24+h;
		sum=sum*60+min;
		sum=sum*60+s;
		ret.push_back(sum);
	}
	sort(ret.begin(),ret.end());
	for(int i=0;i<ret.size();i+=2)
	{
		tmp+=ret[i+1]-ret[i];
	} 
	 cout<<tmp;
	 
	 
	 
	return 0;
 } 
